package com.feng.controller;

import com.feng.dto.LoginUser;
import com.feng.dto.Result;
import com.feng.pojo.Good;
import com.feng.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrderService orderService;

    @PostMapping("/creatInOrder")
    public Result creatInOrder(@RequestBody List<Good> goods, LoginUser loginUser) {
        return orderService.create(goods, loginUser.getId());
    }

    @GetMapping("/creatByGood")
    public Result creatByGood(@RequestParam("googId") Integer goodId, @RequestParam("storeId") Integer storeId, @RequestParam("goodNum") Integer goodNum, LoginUser loginUser) {
        return orderService.create(goodId, storeId, goodNum, loginUser.getId());
    }
    @GetMapping("/pay")
    public Result pay(List<Integer> orderIds) {
        return orderService.pay(orderIds);
    }
}
